#include <iostream>
#include <algorithm>
using namespace std;

const int maxn = 1e5+5;

int cmp(int a,int b){
	return a>b;
}

signed main()
{
	int n;
	cin>>n;
	int a[maxn];
	for(int i=0;i<n;i++)	cin>>a[i];
	sort(a,a+n,cmp);
	int ans = 0;
	for(int i=0;i<n;i++){
		if(a[i]-1>=i+1)	ans = i+1;
	}
	cout<<ans;
	return 0;
}
